import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * Test03
 */
public class Test03 {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new FileReader("/Users/cc/Desktop/Java/day33/a.txt"));
    BufferedWriter bw = new BufferedWriter(new FileWriter("/Users/cc/Desktop/Java/day33/a_copy.txt"));

    // 逐行读取
    String line;
    while ((line = br.readLine()) != null) {
      System.out.println("读取到的数据" + line);
      // 整行写入
      bw.write(line);
      if (br.ready()) {
        // ready()方法返回false值代表马上到文件尾
        bw.newLine(); // 写入一个换行符 BufferedWriter的方法
      }
    }
    // 关闭流
    bw.close();
    br.close();
  }
}